package driverSelf;

import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.Arrays;
public class seleniumDemo {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver","chromedriver.exe");
        ChromeOptions opt=new ChromeOptions();
        opt.addArguments("--disable-blink-feature=AutomationControlled");
        opt.setExperimentalOption("excludeSwitches",new String[]{"enable-automation","load-extension"});
        WebDriver driver=new ChromeDriver(opt);
        driver.get("https://www.baidu.com/");
        driver.manage().window().setPosition(new Point(380,0));
        driver.manage().window().setSize(new Dimension(1544,944));
        WebElement input=driver.findElement(By.cssSelector("#kw"));
        input.sendKeys("夜曲");

            Thread.sleep(1000);
            input.clear();
            Thread.sleep(1000);
            input.sendKeys("json");
            driver.findElement(By.id("su")).click();
            String value=driver.findElement(By.cssSelector("#kw")).getAttribute("value");
if("json".equals(value)){
    System.out.println("验证成功，value的值是"+value);
}
String title=driver.getTitle();
if("json_百度搜索".equals(title)){
    System.out.println("验证成功，title是:"+title);
}
            System.out.println(driver.findElement(By.xpath("//title")).getText());
        }

    }

